/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package canteen.sys.model.entity.repository;

import canteen.sys.model.entity.SubDepartmentMaster;
import canteen.sys.model.generic.GenericHibernateDAOSupport;
import java.util.List;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author TNT
 */
public class SubDepartmentMasterDAOImpl extends GenericHibernateDAOSupport<SubDepartmentMaster, Long> implements SubDepartmentMasterDAO {

    @Override
    public List<SubDepartmentMaster> findAllByStatus(boolean status) {
        Transaction transaction = getSession().beginTransaction();
        List<SubDepartmentMaster> listSubDepartment = getSession().createCriteria(SubDepartmentMaster.class)
                .add(Restrictions.eq("status", status)).list();
        transaction.commit();
        return listSubDepartment;
    }

    @Override
    public List<SubDepartmentMaster> findAllByStatusAndDepartmentId(int departmentId, boolean status) {
        Transaction transaction = getSession().beginTransaction();
        List<SubDepartmentMaster> listSubDepartment = getSession().createCriteria(SubDepartmentMaster.class)
                .add(Restrictions.eq("status", status))
                .add(Restrictions.eq("department.deptId", departmentId)).list();
        transaction.commit();
        return listSubDepartment;
    }
}
